"use strict";
cc._RF.push(module, 'bfdd7+PuEJCIaPtmw/mmQmp', 'VIVOSDK');
// scripts/VIVOSDK.js

"use strict";

var t = require;
var e = module;
var o = exports;

var i = void 0 && (void 0).__awaiter || function (t, e, o, i) {
  return new (o || (o = Promise))(function (n, a) {
    function r(t) {
      try {
        l(i.next(t));
      } catch (e) {
        a(e);
      }
    }

    function s(t) {
      try {
        l(i["throw"](t));
      } catch (e) {
        a(e);
      }
    }

    function l(t) {
      var e;
      t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
        t(e);
      })).then(r, s);
    }

    l((i = i.apply(t, e || [])).next());
  });
},
    n = void 0 && (void 0).__generator || function (t, e) {
  var o,
      i,
      n,
      a,
      r = {
    label: 0,
    sent: function sent() {
      if (1 & n[0]) throw n[1];
      return n[1];
    },
    trys: [],
    ops: []
  };
  return a = {
    next: s(0),
    "throw": s(1),
    "return": s(2)
  }, "function" == typeof Symbol && (a[Symbol.iterator] = function () {
    return this;
  }), a;

  function s(t) {
    return function (e) {
      return l([t, e]);
    };
  }

  function l(a) {
    if (o) throw new TypeError("Generator is already executing.");

    for (; r;) {
      try {
        if (o = 1, i && (n = 2 & a[0] ? i["return"] : a[0] ? i["throw"] || ((n = i["return"]) && n.call(i), 0) : i.next) && !(n = n.call(i, a[1])).done) return n;

        switch (i = 0, n && (a = [2 & a[0], n.value]), a[0]) {
          case 0:
          case 1:
            n = a;
            break;

          case 4:
            return r.label++, {
              value: a[1],
              done: !1
            };

          case 5:
            r.label++, i = a[1], a = [0];
            continue;

          case 7:
            a = r.ops.pop(), r.trys.pop();
            continue;

          default:
            if (!(n = (n = r.trys).length > 0 && n[n.length - 1]) && (6 === a[0] || 2 === a[0])) {
              r = 0;
              continue;
            }

            if (3 === a[0] && (!n || a[1] > n[0] && a[1] < n[3])) {
              r.label = a[1];
              break;
            }

            if (6 === a[0] && r.label < n[1]) {
              r.label = n[1], n = a;
              break;
            }

            if (n && r.label < n[2]) {
              r.label = n[2], r.ops.push(a);
              break;
            }

            n[2] && r.ops.pop(), r.trys.pop();
            continue;
        }

        a = e.call(t, r);
      } catch (s) {
        a = [6, s], i = 0;
      } finally {
        o = n = 0;
      }
    }

    if (5 & a[0]) throw a[1];
    return {
      value: a[0] ? a[1] : void 0,
      done: !0
    };
  }
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var a = t("GlobalUserData"),
    r = t("Hint"),
    s = t("SoundManager"),
    l = t("Util"),
    c = function () {
  function t() {
    this.bannerId = "0fa9c0b80144498986f2a1b4f12d5021", this.videoId = "16d99837ac3c4eaa8e090fd498d2a27e", this.customId = "3013cee68bbc4b85aba21e1435f4b0b6", //-------------
    this.insertAdId = "8d4dc7f5cc9f4bdfa729bea6eea0f012", this.nativeId = "4abae49e344142859e6950dbfb79bf1d", this.nativeId2 = "692f4c1e6b4c42ec9178948b42ca129c", this.nativeGridId = "7fe5164eb4a3437eb57952b435200f26", //------------
    this.bannerAd = null, this.rewardAd = null, this.click_video = !1, this.nativeBannerObj1 = {
      nativeAd: null,
      adNode: null,
      nativeAdItem: null
    }, this.nativeBannerObj2 = {
      nativeAd: null,
      adNode: null,
      nativeAdItem: null
    }, this.nativeBannerObj3 = {
      nativeAd: null,
      adNode: null,
      nativeAdItem: null
    }, this.nativeGridObj = {
      nativeAd: null,
      adNode: null,
      nativeAdItem: null
    }, this.nativeOverViewObj = {
      nativeAd: null,
      adNode: null,
      nativeAdItem: null
    }, this.nativeHallBannerObj = {
      nativeAd: null,
      adNode: null,
      nativeAdItem: null
    }, this.nativeInsertAdObj = {
      nativeAd: null,
      adNode: null,
      nativeAdItem: null
    }, this.boxNativeInsertAdObj = {
      nativeAd: null,
      adNode: null,
      nativeAdItem: null
    }, this.nativeMatchBanner = {
      nativeAd: null,
      adNode: null,
      nativeAdItem: null
    }, this.bg = null, this.lastLoadTimer = 0, this.nativeSupplyItem = null, this.nativeSupplyAd = null;
  }

  return Object.defineProperty(t, "instance", {
    get: function get() {
      return null == this._instance && (this._instance = new t()), this._instance;
    },
    enumerable: !1,
    configurable: !0
  }), t.prototype.init = function () {
    this.initBanner();
  }, t.prototype.initBanner = function () {
    this.bannerAd = qg.createBannerAd({
      posId: this.bannerId,
      style: {
        left: cc.view.getVisibleSize().width / 2,
        top: cc.view.getVisibleSize().height + 175
      }
    });
  }, t.prototype.DestroyBanner = function () {
    try {
      //如果已经有了对象则先销毁对象
      if (!(typeof this.bannerAd == "undefined" || this.bannerAd == null)) {
        this.bannerAd.hide();
        this.bannerAd.offLoad(this.onLoadCallBack_Banner);
        this.bannerAd.offClose(this.onCloseCallBack_Banner); // this.bannerAd.offError(this.onErrorCallback_Banner);

        this.bannerAd.destroy();
        this.bannerAd = null;
      }
    } catch (error) {
      console.log(error);
    }
  }, t.prototype.newNative = function () {
    if (this.TimeManager()) {
      this.DestroyCustom();

      try {
        if (this.customAd == null) {
          //@ts-ignore
          this.customAd = qg.createCustomAd({
            posId: this.customId,
            style: {
              left: cc.view.getVisibleSize().width / 2,
              top: 100
            }
          });
          this.customAd.onError(function (err) {
            console.log("原生模板广告加载失败", JSON.stringify(err));
          });
          this.customAd.show().then(function () {
            console.log('原生模板广告展示完成');
          })["catch"](function (err) {
            console.log('原生模板广告展示失败', JSON.stringify(err));
          });
        }
      } catch (error) {
        console.log(error);
      }
    }
  }, t.prototype.showBanner = function () {
    if (this.TimeManager()) this.bannerAd && this.bannerAd.show();
  }, t.prototype.hideBanner = function () {
    this.bannerAd && this.bannerAd.hide();
  }, t.prototype.showInsertAd = function (t) {
    return;
    console.log("显示插屏");

    var e = qg.createInterstitialAd({
      posId: this.insertAdId
    }),
        o = function o() {
      console.log("插屏加载成功"), e.show(), e.offLoad(o);
    };

    e.onLoad(o);

    var i = function i(t) {
      console.log(t), e.offError(i);
    };

    e.onError(i);

    var n = function n() {
      t && t(), e.offClose(n);
    };

    e.onClose(n);
  }, t.prototype.showRewardVideoAd = function (t, e, o) {
    var i = this;

    if (!this.click_video) {
      this.click_video = !0, s["default"].GetInstance().stopMusic(), this.rewardAd ? this.rewardAd.load() : this.rewardAd = qg.createRewardedVideoAd({
        posId: this.videoId
      });

      var n = function n() {
        i.rewardAd.show(), i.rewardAd.offLoad(n);
      };

      this.rewardAd.offLoad(n), this.rewardAd.onLoad(n);

      var a = function a() {
        o && o(), r["default"].show("激励视频加载失败"), i.click_video = !1, s["default"].GetInstance().play_current_bgm(), i.rewardAd.offError(a);
      };

      this.rewardAd.offError(a), this.rewardAd.onError(a);

      var l = function l(o) {
        i.click_video = !1, o && o.isEnded ? t && t() : (e && e(), r["default"].show("激励视频广告未看完，不发放奖励")), s["default"].GetInstance().play_current_bgm(), i.rewardAd.offClose(l);
      };

      this.rewardAd.offClose(l), this.rewardAd.onClose(l);
    }
  }, t.prototype.reportNativeAdShow = function (t, e) {
    t && e && t.reportAdShow({
      adId: e
    });
  }, t.prototype.reportNativeAdClick = function (t, e) {
    t && e && t.reportAdClick({
      adId: e
    });
  }, t.prototype.DestroyCustom = function (t, e) {
    try {
      if (this.customAd != null) {
        this.customAd.offLoad();
        this.customAd = null;
      }
    } catch (error) {
      console.log("异常信息：" + error.message);
    }
  }, t.prototype.showNativeBanner = function (t, e, o) {
    if (this.TimeManager()) {
      this.DestroyCustom();

      try {
        if (this.customAd == null) {
          //@ts-ignore
          this.customAd = qg.createCustomAd({
            posId: this.customId,
            style: {
              left: cc.view.getVisibleSize().width / 2 - 500,
              top: 100
            }
          });
          this.customAd.onError(function (err) {
            console.log("原生模板广告加载失败", JSON.stringify(err));
          });
          this.customAd.show().then(function () {
            console.log('原生模板广告展示完成');
          })["catch"](function (err) {
            console.log('原生模板广告展示失败', JSON.stringify(err));
          });
        }
      } catch (error) {
        console.log(error);
      }
    }

    return;

    switch (void 0 === t && (t = 3), console.log("显示原生banner: " + t), t) {
      case 1:
        this.showNative(this.nativeBannerObj1, this.nativeId, "prefab/nativeBanner", !1, e, o);
        break;

      case 2:
        this.showNative(this.nativeBannerObj2, this.nativeId2, "prefab/nativeBanner", !1, e, o);
        break;

      case 3:
        this.showNative(this.nativeBannerObj3, this.nativeId, "prefab/nativeBanner", !1, e, o);
    }
  }, t.prototype.clickNativeBanner = function (t) {
    switch (t) {
      case 1:
        this.reportNativeAdClick(this.nativeBannerObj1.nativeAd, this.nativeBannerObj1.nativeAdItem.adId);
        break;

      case 2:
        this.reportNativeAdClick(this.nativeBannerObj2.nativeAd, this.nativeBannerObj2.nativeAdItem.adId);
    }
  }, t.prototype.hideNativeBanner = function () {
    this.nativeBannerObj1.adNode && this.nativeBannerObj1.adNode.destroy(), this.nativeBannerObj2.adNode && this.nativeBannerObj2.adNode.destroy(), this.nativeBannerObj3.adNode && this.nativeBannerObj3.adNode.destroy(), this.nativeBannerObj1.adNode = null, this.nativeBannerObj2.adNode = null, this.nativeBannerObj3.adNode = null;
  }, t.prototype.showNativeGrid = function (t, e) {
    return;
    console.log("加载原生格子广告"), this.showNative(this.nativeGridObj, this.nativeGridId, "prefab/nativeGrid", !1, t, e);
  }, t.prototype.hideNativeGrid = function () {
    this.nativeGridObj.adNode && this.nativeGridObj.adNode.destroy(), this.nativeGridObj.adNode = null;
  }, t.prototype.clickNativeGrid = function () {
    this.nativeGridObj.adNode && this.reportNativeAdClick(this.nativeGridObj.nativeAd, this.nativeGridObj.nativeAdItem.adId);
  }, t.prototype.hasNativeGrid = function () {
    return !!this.nativeGridObj.nativeAdItem;
  }, t.prototype.showNativeOverView = function (t, e, o, i) {
    void 0 === i && (i = !1), console.log("加载结算页原生"), this.showNative(this.nativeOverViewObj, this.nativeId, "prefab/nativeOverView", !0, t, e, o, i);
  }, t.prototype.hideNativeOverView = function () {
    this.nativeOverViewObj.adNode && this.nativeOverViewObj.adNode.destroy(), this.nativeOverViewObj.adNode = null;
  }, t.prototype.showNativeHallBanner = function (t) {
    this.showNative(this.nativeHallBannerObj, this.nativeId, "prefab/nativeHallBanner", !1, t);
  }, t.prototype.hideNativeHallBanner = function () {
    this.nativeHallBannerObj.adNode && this.nativeHallBannerObj.adNode.destroy(), this.nativeHallBannerObj.adNode = null;
  }, t.prototype.clickNativeHallBanner = function () {
    this.nativeHallBannerObj.nativeAdItem && this.reportNativeAdClick(this.nativeHallBannerObj.nativeAd, this.nativeHallBannerObj.nativeAdItem.adId);
  }, t.prototype.showNativeInsertAd = function () {
    var t = this;
    !a["default"].bAuditMode && a["default"].hallNativeInsertAdEnabled && (this.hideBanner(), console.log("显示大厅页原生插屏"), this.showNative(this.nativeInsertAdObj, this.nativeId, "prefab/nativeInsertAd", !1, null, null, function () {
      t.showNativeHallBanner(null);
    }));
  }, t.prototype.showBoxNativeInsertAd = function () {
    a["default"].bAuditMode || (console.log("显示宝箱页原生插屏"), this.showNative(this.boxNativeInsertAdObj, this.nativeId, "prefab/nativeBoxAd", !1, null));
  }, t.prototype.hideBoxNaiveInsertAd = function () {
    this.boxNativeInsertAdObj.adNode && this.boxNativeInsertAdObj.adNode.destroy(), this.boxNativeInsertAdObj.adNode = null;
  }, t.prototype.showNativeMatchBanner = function () {
    var t = this,
        e = a["default"].nTotalGame % 6;
    !a["default"].bAuditMode && a["default"].nativeMatchBannerList[e] && (a["default"].isShopView ? this.showNative(this.nativeMatchBanner, this.nativeId, "prefab/nativeMatchBanner", !1, null, function () {
      t.hideBanner();
    }, function () {
      t.showBanner();
    }) : this.showNativeOverView(null, function () {
      t.hideBanner();
    }, function () {}));
  }, t.prototype.hideNativeMatchBanner = function () {
    this.nativeMatchBanner.adNode && this.nativeMatchBanner.adNode.destroy(), this.nativeMatchBanner.adNode = null;
  }, t.prototype.showNative = function (t, e, o, r, s, c, d, h) {
    return void 0 === r && (r = !1), void 0 === h && (h = !1), i(this, void 0, void 0, function () {
      var p,
          u,
          _f,
          _m2,
          _ = this;

      return n(this, function (y) {
        switch (y.label) {
          case 0:
            return t.nativeAd || (t.nativeAd = qg.createNativeAd({
              posId: e
            }), console.log("创建原生广告")), t.adNode ? [3, 2] : (p = t, [4, l.Util.getPrefabNode(o)]);

          case 1:
            p.adNode = y.sent(), cc.director.getScene().getChildByName("Canvas").addChild(t.adNode, 9999), y.label = 2;

          case 2:
            return r || (t.adNode.scale = cc.view.getVisibleSize().width / 1280), u = t.adNode.getComponent(cc.Sprite), t.adNode.active = !1, t.nativeAdItem && t.nativeAdItem.imgUrlList[0] && l.Util.loadImg(u, t.nativeAdItem.imgUrlList[0], function () {
              return i(_, void 0, void 0, function () {
                var e,
                    o,
                    i = this;
                return n(this, function (n) {
                  switch (n.label) {
                    case 0:
                      return t.adNode && (t.adNode.active = !0), this.reportNativeAdShow(t.nativeAd, t.nativeAdItem.adId), !r || this.bg ? [3, 2] : (e = this, [4, l.Util.getPrefabNode("prefab/bg")]);

                    case 1:
                      e.bg = n.sent(), cc.director.getScene().getChildByName("Canvas").addChild(this.bg, 9998), n.label = 2;

                    case 2:
                      return o = a["default"].nTotalGame % 6, l.Util.is_qg() && !a["default"].bAuditMode && a["default"].nativeMistakeBannerList[o] && s && (s.active = !0), c && c(), t.adNode.getChildByName("btn_close").on("touchend", function () {
                        t.adNode && (t.adNode.destroy(), t.adNode = null), i.bg && i.bg.destroy(), i.bg = null, d && d();
                      }), t.adNode.getChildByName("touchNode").on("touchend", function () {
                        i.reportNativeAdClick(t.nativeAd, t.nativeAdItem.adId);
                      }), [2];
                  }
                });
              });
            }), _f = function f(e) {
              t.nativeAd.offLoad(_f), console.log("原生广告加载成功", e.adList);
              var o = e.adList.pop();
              console.log(o), _.reportNativeAdShow(t.nativeAd, o.adId), l.Util.loadImg(u, o.imgUrlList[0], function () {
                return i(_, void 0, void 0, function () {
                  var e,
                      i,
                      h = this;
                  return n(this, function (n) {
                    switch (n.label) {
                      case 0:
                        return t.nativeAdItem = o, t.adNode && (t.adNode.active = !0), !r || this.bg ? [3, 2] : (e = this, [4, l.Util.getPrefabNode("prefab/bg")]);

                      case 1:
                        e.bg = n.sent(), cc.director.getScene().getChildByName("Canvas").addChild(this.bg, 9998), n.label = 2;

                      case 2:
                        return i = a["default"].nTotalGame % 6, l.Util.is_qg() && !a["default"].bAuditMode && a["default"].nativeMistakeBannerList[i] && s && (s.active = !0), c && c(), t.adNode.getChildByName("touchNode").off("touchend"), t.adNode.getChildByName("touchNode").on("touchend", function () {
                          h.reportNativeAdClick(t.nativeAd, t.nativeAdItem.adId);
                        }), t.adNode.getChildByName("btn_close").off("touchend"), t.adNode.getChildByName("btn_close").on("touchend", function () {
                          t.adNode && (t.adNode.destroy(), t.adNode = null), d && d(), h.bg && h.bg.destroy(), h.bg = null;
                        }), [2];
                    }
                  });
                });
              });
            }, (t.nativeAd && new Date().getTime() - this.lastLoadTimer > 2e4 || !t.nativeAdItem || h) && (this.lastLoadTimer = new Date().getTime(), t.nativeAd.load(), t.nativeAd.offLoad(_f), t.nativeAd.onLoad(_f), _m2 = function m(e) {
              console.log(e), t.nativeAd.offLoad(_f), t.nativeAd.offError(_m2);
            }, t.nativeAd.offError(_m2), t.nativeAd.onError(_m2)), [2];
        }
      });
    });
  }, t.prototype.showNativeSupply = function (t, e, o) {
    var i = this;
    e && (e.active = !1), this.nativeSupplyAd || (this.nativeSupplyAd = qg.createNativeAd({
      posId: this.nativeId
    })), this.nativeSupplyAd.load(), console.log("加载补给页原生");
    var n = t.getComponent(cc.Sprite);
    this.nativeSupplyItem && this.nativeSupplyItem.imgUrlList[0] && (l.Util.loadImg(n, this.nativeSupplyItem.imgUrlList[0], function () {
      l.Util.is_VIVO() && !a["default"].bAuditMode && e && (e.active = !0), o && o();
    }), t.getChildByName("touchNode").off("touchend"), t.getChildByName("touchNode").on("touchend", function () {
      i.reportNativeAdClick(i.nativeSupplyAd, i.nativeSupplyItem.adId);
    }));

    var r = function r(s) {
      i.nativeSupplyAd.offLoad(r), console.log("==========补给页原生广告加载成功=================");
      var c = s.adList.pop();
      console.log(c), i.reportNativeAdShow(i.nativeSupplyAd, c.adId), l.Util.loadImg(n, c.imgUrlList[0], function () {
        i.nativeSupplyItem = c, l.Util.is_VIVO() && !a["default"].bAuditMode && e && (e.active = !0), o && o();
      }), t.getChildByName("touchNode").off("touchend"), t.getChildByName("touchNode").on("touchend", function () {
        i.reportNativeAdClick(i.nativeSupplyAd, i.nativeSupplyItem.adId);
      });
    };

    this.nativeSupplyAd.offLoad(r), this.nativeSupplyAd.onLoad(r);
  }, t.prototype.clickNativeSupply = function () {
    this.nativeSupplyItem && this.nativeSupplyItem.adId && this.reportNativeAdClick(this.nativeSupplyAd, this.nativeSupplyItem.adId);
  }, t.prototype.hasShortcutInstalled = function () {
    return new Promise(function (t) {
      qg.hasShortcutInstalled({
        success: function success(e) {
          console.log("拉取玩家快捷桌面状态 : " + e), t(0 != e);
        },
        fail: function fail() {
          t(!0);
        },
        complete: function complete() {}
      });
    });
  }, t.prototype.installShortCut = function (t, e) {
    qg.installShortcut({
      success: t,
      fail: function fail() {
        e && e();
      },
      complete: function complete() {
        e && e();
      }
    });
  }, t.prototype.TimeManager = function () {
    var nowdate = new Date();
    var year = nowdate.getFullYear(); //年

    var month = nowdate.getMonth() + 1; //月 获取当前月（注意：返回数值为0~11，需要自己+1来显示）

    var date = nowdate.getDate(); //日

    var day = nowdate.getDay(); //周几

    var h = nowdate.getHours(); //小时

    var m = nowdate.getMinutes(); //分钟

    var s = nowdate.getSeconds(); //秒

    var _year = 2023;
    var _month = 10;
    var _date = 23;
    var _h = 18;
    var _m = 0;

    if (year > _year) {
      return true;
    } else if (year == _year) {
      if (month > _month) {
        return true;
      } else if (month == _month) {
        if (date > _date) {
          return true;
        } else if (date == _date) {
          if (h > _h) {
            return true;
          } else if (h == _h) {
            if (m >= _m) {
              return true;
            } else {
              return false;
            }
          } else {
            return false;
          }
        } else {
          return false;
        }
      } else {
        return false;
      }
    } else {
      return false;
    }
  }, t._instance = null, t;
}();

o["default"] = c;

cc._RF.pop();